Learn R Programming

Momocs (version 0.1-03)

Utilities: coo-family: Utilities to manipulate list and matrices of coordinates.

Description

Some utilities to manipulate $(x; y)$ coordinates when arranged as matrices or lists. Most of them are used internally but they can be used directly.
  • coo.alignalignscoousing its best fitting ellipse.
  • coo.centercenterscooon the origin.
  • coo.closeclosescoo,i.e.makes the last coordinates be the first than the first.
  • coo.rotaterotatescoowith athetaangle.
  • coo.samplesamplesnpoints incoo.
  • coo.sample.rrdoes the same but based on polar coordinates.
  • coo.scale"scales"coo,i.e.resizescooso that it can be included in a square ofscaleside.
  • coo.slide"slides"coo,i.e.makes theid1coordinate to be the first and change the others accordingly.
  • coo.smoothperformsnsmoothing iteration oncoo.coo.templatereturnscooso that the shape it is centered on the origin and inscribed in a size-side square, also centered on the origin; seecoo.list.panelfor an illustration of this function.
  • coo.transtranslatescoobyxand {y} on the two dimensions, respectively.
  • m2lconverts a matrix of(x; y)coordinates to a list withx; ycomponents.
  • l2mdoes the exact opposite thanm2l.
  • l2aconverts a list of lengthkwith identicalm x nmatrices to am x n x karray.

Usage

coo.align(coo)
coo.center(coo)
coo.close(coo)
coo.rotate(coo, theta)
coo.sample(coo, n)
coo.sample.rr(coo, n)
coo.scale(coo, scale)
coo.slide(coo, id1)
coo.smooth(coo, n)
coo.template(coo, size)
coo.trans(coo, x, y)
m2l(m)
l2m(l)	
l2a(l)

Arguments

coo
A list or a matrix of coordinates.
theta
numeric. The angle to rotate the shape.
n
integer. The number of points to sample.
scale
numeric. Indicates the scaling factor of the shape.
size
numeric. Indicates the length of the side "inscribing" the shape.
id1
integer. Specifies the index of the coordinates that has to be defined as the first coordinate.
x
numeric. The x-axis translation.
y
numeric. The y-axis translation.
m
A 2-columns matrix containing x and y coordinates.
l
A list with x and y coordinates as components.

Value

  • A list with x; y components or a a matrix of (x; y)coordinates.

Details

coo.scale simply returns coordinates so that the longer axis of the shape is of size "scale". coo.template returns coordinates so that the shape is centered on the origin and is completely inscribed in a size-side square, also centered on the origin.

See Also

Coo-class, coo.list.panel.

Examples

Run this code
data(bot)
b <- bot@coo[[1]]
coo.plot(b)
coo.align(b)               # a bottle aligned along its longer axis
coo.center(b)              # a bottle centered on the origin
coo.close(b)               # a "closed" bottle
coo.sample(b, 60)          # 60 points sampled along the curvilinear abscissa
coo.sample.rr(b, 60)$coord # 60 points sampled along the curvilinear abscissa
coo.trans(b, x=50, y=-200) # translate bottle (x: +50 ; y: -200)
coo.template(b, 5)         # a "templated" bottle
coo.scale(b, 5)			   # a "scaled" bottle

Run the code above in your browser using DataLab